Skip to content

Conversation

@atiq-bs23
Copy link
Contributor

@atiq-bs23 atiq-bs23 commented Nov 20, 2025

This PR adds TableFor, ColumnFor and FromTable extension methods for IDeleteExpressionRoot, IAlterExpressionRoot, and ISchemaExpressionRoot to ensure table and column names are resolved via NameCompatibilityManager.

Supports schema checks, altering, adding, and deleting columns in a type-safe manner.

Includes strongly-typed column selector overloads for safer refactoring.

Updated XML summaries for all new methods for consistency with existing extension methods.

Note: Changes in SchemaMigration are only for reference purposes.
These changes will not affect any existing migrations since the NopSchemaMigration attribute date has not been modified, and the migration will not execute.

Now we can write like below

 if (!Schema.TableFor<Topic>().ColumnFor<Topic>(t => t.AvailableEndDateTimeUtc).Exists())
 {
     Alter.TableFor<Topic>()
         .AddColumnFor<Topic>(t => t.AvailableEndDateTimeUtc)
         .AsDateTime()
         .Nullable();
 }
 
var footerColumn1ColumnName = "IncludeInFooterColumn1";
if (Schema.TableFor<Topic>().Column(footerColumn1ColumnName).Exists())
    Delete.Column(footerColumn1ColumnName).FromTable<Topic>();

@atiq-bs23
Copy link
Contributor Author

#7967 #7952 related

@atiq-bs23
Copy link
Contributor Author

@skoshelev Thanks for your feedback, I'll mention you once all comments resolved.

@skoshelev
Copy link
Contributor

Hi @atiq-bs23!

Thank you very much for your help.

I looked at the code and left a couple of suggestions. Please make the necessary changes. Also, modify older migrations so that the code seems consistent across the entire codebase.

@atiq-bs23
Copy link
Contributor Author

@skoshelev I resolved all comments, please merge this one so that I can create a new PR for updating all existing migrations

@atiq-bs23
Copy link
Contributor Author

There are a lot of changes in existing migrations and also I found some code where NameCompatibility is not considered. So I think it would be good to have it in a separate PR.

@skoshelev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add TableFor and ColumnFor support for Alter, Delete and Schema operations using NameCompatibilityManager

3 participants